<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../css/header.css" />
	</head>

	<body>

		<header class="mui-bar mui-bar-nav title">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color: white;"></a>
			<h1 class="mui-title title-color">学生实习报告列表</h1>
		</header>

		<div class="mui-content">
			
			<ul class="mui-table-view" id="student_report_html_list" style="margin-bottom: 10px;">
				
				<!-- <li class="btnOper mui-table-view-cell mui-media">
					<a href="javascript:;">
						<img class="mui-media-object mui-pull-left" src="../../images/1.jpg">
						<span id="span_nickname" class="mui-pull-right">
							<button type="button" class="passRequest mui-btn mui-btn-green" style="padding: 4px 10px;">批改</button>
						</span>
						<div class="mui-media-body">
							<label>学生:XXX</label>
							<p class="mui-ellipsis">实习公司:XXXXXX</p>
						</div>
					</a>
				</li> --> -->
			</ul>

		</div>

		<script src="../../js/mui.min.js"></script>
		<script src="../../js/app.js"></script>
		<script type="text/javascript">
			mui.init()

			mui.plusReady(function() {
				var user = app.getGlobalUserInfo();
				
				loadingStudentReport();
			});
			
			// 加载学生实习报告列表
			function loadingStudentReport(){
				var teacher = app.getGlobalUserInfo();
				
				mui.ajax(app.serverUrl + "/user/teacher/query_syudent_report?user_id=" + teacher.user_id, {
					data: {},
					dataType: 'json', //服务器返回json格式数据
					type: 'post', //HTTP请求类型
					timeout: 10000, //超时时间设置为10秒；
					headers: {
						'Content-Type': 'application/json'
					},
					success: function(data) {
						if (data.status == 200) {
							var studentReportInfoList = data.data;
							
							var student_report_html_list = document.getElementById("student_report_html_list");
							
							if (studentReportInfoList != null && studentReportInfoList.length > 0) {
								var student_report_html = "";
								for (var i = 0; i < studentReportInfoList.length; i++) {
									student_report_html += studentReportHtml(studentReportInfoList[i]);
								}
								student_report_html_list.innerHTML = student_report_html;
							} else {
								student_report_html_list.innerHTML = "";
							}
							
							//动态对批改按钮进行事件绑定
							mui(".btnOper").on("tap", ".seeReport", function(e) {
								
								var reportTitle = this.getAttribute("reportTitle");
								var reportContent = this.getAttribute("reportContent");
								var studentId = this.getAttribute("studentId");
								var reportRemark = this.getAttribute("reportRemark");
								var reportMark = this.getAttribute("reportMark");
								
								// console.log(reportRemark);
								
								// 打开报告详情页面
								mui.openWindow({
									url: "studentInternshipReport.html",
									id: "studentInternshipReport-" + studentId, // 每个报告页面都是唯一对应的
									extras: {
										reportTitle: reportTitle,
										reportContent: reportContent,
										reportRemark: reportRemark,
										reportMark: reportMark
									}
								});					
							});
							
						} else {
							app.showToast("获取数据失败，请重试！", "error");
						}
					}
				});
			}
			
			// 学生实习报告列表html
			function studentReportHtml(studentReportInfo){
				
				var correct_info = "";
				if (studentReportInfo.ir_mark != null && studentReportInfo.ir_mark != '') {
					correct_info = '<p class="mui-ellipsis">批改情况:已批改&nbsp;&nbsp;&nbsp;成绩:' + studentReportInfo.ir_mark + '</p>';
				} else {
					correct_info = '<p class="mui-ellipsis">批改情况:未批改</p>';
				}
				
				var html = "";
				html = '<ul class="mui-table-view" id="ul_enterprise_list" style="margin-bottom: 10px;">' +
				'<li class="btnOper mui-table-view-cell mui-media">' +
					'<a href="javascript:;">' +
						'<img style="max-width: 60px; height: 60px;" class="mui-media-object mui-pull-left" src="' + app.imgServerUrl + studentReportInfo.head_portrait_url_small + '">' +
						'<span id="span_nickname" class="mui-pull-right">' +
							'<button reportMark="' + studentReportInfo.ir_mark + '" reportRemark="' + studentReportInfo.ir_remark + '" reportContent="' + studentReportInfo.ir_content + '" reportTitle="' + studentReportInfo.ir_id + '" studentId="' + studentReportInfo.ir_stu_id + '" type="button" class="seeReport mui-btn mui-btn-green" style="padding: 4px 10px;">批改</button>' +
						'</span>' +
						'<div class="mui-media-body">' +
							'<label>学生:' + studentReportInfo.s_name + '</label>' +
							'<p class="mui-ellipsis">实习公司:' + studentReportInfo.e_name + '</p>' +
						'</div>' +
						correct_info +
					'</a>' +
				'</li>' +
			'</ul>';
			return html;
			}
		</script>
	</body>

</html>